package com.example.demo.common.utils;

import com.example.demo.common.pojo.dataobject.BlogInfo;
import com.example.demo.common.pojo.dataobject.UserInfo;
import com.example.demo.common.pojo.request.AddBlogParam;
import com.example.demo.common.pojo.request.UpBlogParam;
import com.example.demo.common.response.BlogInfoResponse;
import com.example.demo.common.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

public class BeanConver {

    public static BlogInfoResponse trans(BlogInfo blogInfo){
        BlogInfoResponse blogInfoResponse = new BlogInfoResponse();
        if(blogInfo != null){
            BeanUtils.copyProperties(blogInfo,blogInfoResponse);
        }
        return blogInfoResponse;
    }

    public static UserInfoResponse trans(UserInfo userInfo){
        UserInfoResponse userInfoResponse = new UserInfoResponse();
        if(userInfo != null){
            BeanUtils.copyProperties(userInfo, userInfoResponse);
        }
        return userInfoResponse;
    }

    public static BlogInfo trans(AddBlogParam param){
        BlogInfo blogInfo = new BlogInfo();
        if(param != null){
            BeanUtils.copyProperties(param,blogInfo);
        }
        return blogInfo;
    }

    public static BlogInfo trans(UpBlogParam param) {
        BlogInfo blogInfo = new BlogInfo();
        if(param != null){
            BeanUtils.copyProperties(param, blogInfo);
        }
        return blogInfo;
    }
}
